package com.fjeld.client.gui.control.navigation;

import static com.fjeld.swingx.ColorConstants.BLACK;
import static com.fjeld.swingx.ColorConstants.SIDEBAR_BG;
import com.fjeld.swingx.JBorderLayoutPanel;
import com.fjeld.swingx.JTransparentPanel;
import com.fjeld.swingx.JTransparentScrollPane;

import javax.swing.*;
import java.awt.*;

/**
 * Shows a side bar used for navigating in the application.
 */
public class SideBar extends JBorderLayoutPanel
{
    private static final SideBar INSTANCE = new SideBar();

    private JTransparentPanel listingPanel = new JTransparentPanel();

    private SideBar()
    {
        setBackground(SIDEBAR_BG);
        add(new NavPanel(), BorderLayout.NORTH);

        JTransparentScrollPane scroller = new JTransparentScrollPane(listingPanel);
        add(scroller, BorderLayout.CENTER);
        setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, BLACK));
        listingPanel.revalidate();
        listingPanel.repaint();
    }

    public void displayContentPanel(JComponent component)
    {
        listingPanel.add(component, BorderLayout.NORTH);
    }

    public static SideBar getINSTANCE()
    {
        return INSTANCE;
    }
}
